import {Injectable} from '@angular/core';
import {Subscription} from "rxjs/Subscription";
import {HttpService} from "@core/http/http.service";
import {ToolsService} from "@shared/service/tools/tools.service";
import * as API from "@api/index";

@Injectable()
export class InvestmentService {

  subscription: Subscription = new Subscription();
  constructor(
    public httpService: HttpService,
    public toolsService: ToolsService,
  ) {
  }

  getSponsorList(data) {
    let url = API.SPONSOR_INVITE_LIST ;
    return this.httpService.postJson(url, data).map((res)=>res.json());
  }

  getInvestmentDetail(data) {
    let url = API.SPONSOR_INVITE_DETAIL + `?sponsorId=${data}`;
    return this.httpService.get(url).map((res)=>res.json());
  }

  addContactInfo(data) {
    let url = API.SPONSOR_CONTACT_ADD;
    return this.httpService.postUrlencode(url, data).map((res)=>res.json());
  }

  getEventDetailInfo(data) {
    let url = API.PERSON_EVENTS_DETAIL_DETAIL + `?matchId=` + data;
    return this.httpService.get(url).map((res)=>res.json());
  }

  getInvestmentPlan(data) {
    let url = API.INVESTMENT_PLAN + `?sponsorId=` + data;
    return this.httpService.get(url).map((res)=>res.json());
  }

  getInvestmentContact(data) {
    let url = API.INVESTMENT_CONTACT + `?sponsorId=` + data;
    return this.httpService.get(url).map((res)=>res.json());
  }

  getFilterInfo() {
    let url = API.SPONSOR_FILTER + `?type=1`;
    return this.httpService.get(url).map((res)=>res.json());
  }
}
